﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
    <link href="/lib/jquery/jquery-ui.min.css" rel="stylesheet" />
    <script src="/lib/jquery/jquery-ui.min.js"></script>
    <script src="/lib/date/wdatepicker.js"></script>
</head>
<body>
    <div class="data-wrap case" id="container">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline">
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch">
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">IP：</label>
                        <input class="form-control" name="IP" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">创建者名称：</label>
                        <input class="form-control" name="CreateName" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">日志类型：</label>
                        <select class="form-control" name="LogType" id="LogType"></select>
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">日志日期：</label>
                        <input id="d421" class="Wdate wd125" name="CreateDate" type="text" onfocus="WdatePicker({maxDate:'%y-%M-%d'})" />
                    </div>

                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>

    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-body data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="t_l wd100">IP</th>
                                <th class="t_l">LOG类型</th>
                                <th class="t_l wd100">创建者名称</th>
                                <th class="wd150">创建时间</th>
                                <th class="t_l">备注</th>
                                <th class="t_l wd150">公司名称</th>
                                <th class="t_l">操作地址</th>
                                <th class="t_l">操作信息</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{? it.tData && it.tData.length>0}}
                            {{~it.tData :item:index}}
                            <tr>
                                <td class="t_l wd100">{{= item.ip }}</td>
                                <td class="t_l">{{= item.logType }}</td>
                                <td class="t_l wd100">{{= item.createName }}</td>
                                <td class="wd150">{{= FlashPay.Util.FormatDate(item.createDate) }}</td>
                                <td class="t_l" title={{= item.logRemark }}>{{= FlashPay.Util.GetShortStr(item.logRemark) }}</td>
                                <td class="t_l wd150">{{= item.companyName }}</td>
                                <td class="t_l" title={{= item.requestUrl }}>{{= item.requestUrl }}</td>
                                <td class="t_l" title={{= item.requestData }}>{{= FlashPay.Util.GetShortStr(item.requestData,30) }}</td>
                            </tr>
                            {{~}}
                            {{??}}
                            <tr class="noRecord">
                                <td colspan="8">暂无记录！</td>
                            </tr>
                            {{?}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">
        var LogType = $("select[name='LogType']");
        $(function () {
            FlashPay.UI.DataAutoHeight();
            getLogTypes();
            doSearch();
            //搜索
            $("#btnSearch").click(function () {
                doSearch();
            });
            $(".form-control").bind('keydown', function (event) {
                if (event.keyCode == "13") {
                    doSearch();
                }
            });
        });
        function doSearch() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager", pageSize: 15, ajax: { url: '/LogRecord/Get', Method: 'Post' } });
        }
        function getLogTypes() {
            FlashPay.Util.Ajax({
                type: "POST",
                url: "/LogRecord/GetLogTypes",
                data: null,
                dataType: "json",
                contentType: "application/json",
                success: function (response) {

                    if (response != null) {
                        LogType.append("<option value=''>请选择</option>");
                        $.each(response, function (i, item) {
                            LogType.append("<option value='" + item + "'>" + item + "</option >");
                        });
                    }
                }
            });
        }
        function Tip_success(word) {
            FlashPay.UI.Tip_success(word);
        }

        //创建者名称搜索
        $("input[name='CreateName']").autocomplete({
            minLength: 1,
            source: function (request, response) {
                FlashPay.Util.Ajax({
                    url: '/User/SearchUserInfo',
                    type: 'POST',
                    data: { SearchValue: $("input[name='CreateName']").val() },
                    success: function (res) {
                        if (res.success) {
                            if (res.data != null && res.data.length > 0) {
                                response($.map(res.data, function (item) {
                                    return {
                                        label: item.uLoginName,
                                        value: item.uLoginName,
                                        id: item.uId
                                    }
                                }))
                            }
                        } else {
                            FlashPay.UI.Tip_warning("操作失败！" + res.errorMessage);
                        }
                    },
                    error: function (json) {
                        FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试。");
                    }
                });
            }
        });
    </script>
</body>
</html>